<template>
  <div class="history">
     <goBack title="历史记录"></goBack>
    <div @click="goToDetail(item.id)" v-for="item in info" :key="item" class="history-item">
      <div class="title">
        <div class="title-1">{{item.phone}}</div>
        <div class="title-2">测试时间：{{item.createtime}}</div>
      </div>
      <div class="title">
        <div class="title-1"></div>
        <div class="btn">查看详情</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRoute } from 'vue-router';

import goBack from '../../components/goBack.vue';
import { useRouter } from 'vue-router';
import { getRecordinfo,getRecord } from '../../api/apiList/homePage.js';
const route = useRoute();
import { onMounted, ref } from 'vue';
const router = useRouter();
const goToDetail = (id) => {
  getRecordinfo({token: sessionStorage.getItem('PHONE-TOKEN'), id}).then((res)=>{
    router.push({
      path: '/list',
      query: { list: encodeURIComponent(JSON.stringify(res.result)) }
    });
  })
};

let info = ref({});

onMounted(async () => {
  // 获取列表数据 0招生信息 1大学推荐
    await getRecord({token:sessionStorage.getItem('PHONE-TOKEN')}).then((res) => {
    const { result } = res;
    info.value = result;
  });
});
</script>

<style lang="less" scoped>
.history {
    padding: 0 8px;
    margin-top: 100px;
    
  .history-item {
    height: 94px;
    background-image: url('../../assets/images/history.png');
    margin-top: 12px;
    background-size: 100% auto;
    background-repeat: no-repeat; 
    padding: 4px 23px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    .title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 12px;
      .title-1 {
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 25px;
      }
      .title-2 {
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 25px;
      }
    }
    .btn {
        width: 85px;
        height: 27px;
        border-radius: 16px;
        border: 1px solid #C5B6FD;
        font-size: 13px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #000000;
        line-height: 27px;
        text-align: center;
    }
  }
}
</style>
